//
//  BarrierViewController.m
//  ObjcGoNew
//
//  Created by 邢伟新 on 2021/4/15.
//

#import "BarrierViewController.h"

@interface BarrierViewController ()

@end

@implementation BarrierViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"栅栏函数";
    self.view.backgroundColor = [UIColor whiteColor];
    [self test1];
    
}

//栅栏函数的基本使用
-(void)test1{
    
    dispatch_queue_t queue = dispatch_queue_create("xingweixin", DISPATCH_QUEUE_CONCURRENT);
    
    NSLog(@"1_______________%@",[NSThread currentThread]);
    
    dispatch_async(queue, ^{
       
        NSLog(@"2_______________%@",[NSThread currentThread]);
    });
    
    dispatch_async(queue, ^{
        NSLog(@"3_______________%@",[NSThread currentThread]);
    });
    
    dispatch_async(queue, ^{
        NSLog(@"4_______________%@",[NSThread currentThread]);
    });
    
    dispatch_async(queue, ^{
        NSLog(@"5_______________%@",[NSThread currentThread]);
    });
    
    //来个栅栏
    dispatch_barrier_async(queue, ^{
        NSLog(@"栅栏拦截--------%@",[NSThread currentThread]);
    });
    
    
    dispatch_async(queue, ^{
        NSLog(@"6_______________%@",[NSThread currentThread]);
    });
    
    dispatch_async(queue, ^{
        NSLog(@"7_______________%@",[NSThread currentThread]);
    });
    
    NSLog(@"8_______________%@",[NSThread currentThread]);
    

    
}



@end
